package cn.argentoaskia.crm.controller;

import cn.argentoaskia.crm.bean.Department;
import cn.argentoaskia.crm.result.ResponseData;
import cn.argentoaskia.crm.service.select.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @GetMapping("/department")
    public ResponseData getDepartmentList() {
        ResponseData responseData = new ResponseData ();
        List<Department> list = departmentService.getDepartmentList ();
        if (list != null) {
            responseData.setCode (200);
            responseData.setCount (null);
            responseData.setInfo ("success");
            responseData.setData (list);
        } else {
            responseData.setCode (502);
            responseData.setCount (null);
            responseData.setInfo ("身份信息过期");
            responseData.setData (null);
        }

        return responseData;
    }
}
